package com.design_pattern._01_create._02_builder;

public class TestDriver {
    public static void main(String[] args) {
        // 修改之前：无默认值、结构杂乱（可能name在前面设置，age在最后面设置），可读性差，可能漏掉字段
        Bad bad = new Bad();
        bad.name= "zhangsan";
        bad.CityName= "beijing";
        bad.age = 13;
        // 此时会发生：漏掉好几个字段，可读性差，无默认值/需要手动填写，或者是冗长的构造方法，但是字段有50个怎么办

        // 修改之后：可以设置默认值，可以在build中进行检查，分类清晰明确
        Person build = Person.getBuilder().buildBasic("name", 30, 177).buildLoc("青岛", "120", "40").build();

    }
}

class Bad {

    String name;
    int age;
    int height;
    String CityName;
    String CityLatitude;
    String CityLongitude;

    public Bad() {
    }

    public Bad(String name,
               int age,
               int height,
               String CityName,
               String CityLatitude,
               String CityLongitude) {
        this.name = name;
        this.age = age;
        this.height = height;
        this.CityName = CityName;
        this.CityLatitude = CityLatitude;
        this.CityLongitude = CityLongitude;
    }
}